<?php
/**
 * Enter description here ...
 * @author Micou13630
 *
 */
class TreeGrid extends ListGrid implements IRenderable {
	
	protected $autoFetchTextMatchStyle;
	
	protected $canAcceptDroppedRecords;
	protected $canDragRecordsOut;
	protected $canDropOnLeaves;
	protected $dragDataAction;
	
	protected $canReorderRecords;
	protected $canReparentNodes;
	
	protected $cascadeSelection;
	
	protected $indentRecordComponents;
	protected $indentSize;
	
	protected $fields;
	protected $data;
	protected $dataSource;
	protected $initialData;
	protected $treeRootValue;
	
	protected $loadDataOnDemand;
	protected $offlineNodeMessage;
	
	protected $displayNodeType;
	
	protected $extraIconGap;
	
	protected $iconSize;
	protected $folderIcon;
	protected $nodeIcon;
	protected $manyItemsImage;
	protected $openerImage;
	protected $openerIconSize;
	
	protected $seperateFolders;
	protected $showConnectors;
	protected $showDropIcons;
	protected $showFullConnectors;
	protected $showOpener;
	protected $showOpenIcons;
	protected $showPartialSelection;
	protected $showRoot;
	
	protected $sortFoldersBeforeLeaves;
	
	protected $treeFieldTitle;
	
	/**
	 * Constructeur
	 * @param unknown_type $id
	 */
	public function TreeGrid ($id) {
		parent::ListGrid($id);
		
		$this->fields = array();
		$this->initialData = array();
	}

	/**
	 * Ajouter un champ
	 * @param ListGridField $field
	 */
	public function addField(TreeGridField $field) {
		$this->fields[] = $field;
	}
	
	/**
	 * Defini le recordClick
	 * @param unknown_type $expression
	 */
	public function setJSRecordClick($expression) {
		$func = new FunctionType(array('viewer', 'record', 'recordNum', 'field', 'fieldNum', 'value', 'rawValue'), $expression);
		$this->recordClick = $func;
	}
	
	/**
	 * Defini le recordDoubleClick
	 * @param unknown_type $expression
	 */
	public function setJSRecordDoubleClick($expression) {
		$func = new FunctionType(array('viewer', 'record', 'recordNum', 'field', 'fieldNum', 'value', 'rawValue'), $expression);
		$this->recordDoubleClick = $func;
	}
	
	/**
	 * Implementation de object
	 * @see IRenderable::object()
	 */
	public function object() {
		return get_class($this);
	}

	/**
	 * Implementation de properties
	 * @see IRenderable::properties()
	 */
	public function properties() {
		return parent::getProp($this);
	}

	/**
	 * Implementation de scLog
	 * @see IRenderable::scLog()
	 */
	public function scLog() {
		ScCollectionLog::getInstance()->addSc(new ScLog($this->object(), get_object_vars($this)));
	}
	
	/**
	 * Implementation de render
	 * @see IScreen::render()
	 */
	public function render() {
		$this->scLog();
		return "isc.".$this->object().".create({".$this->properties()."})";
	}
}

/**
 * Enter description here ...
 * @author Micou13630
 *
 */
class TreeGridField extends ListGridField implements IRenderable {

	protected $treeField;
	
	/**
	 * Enter description here ...
	 * @param unknown_type $name
	 * @param unknown_type $title
	 * @param unknown_type $type
	 * @param unknown_type $witdh
	 */
	public function ListGridField($name, $title, $type = null, $witdh = null) {
		$this->name = $name;
		$this->title = $title;
		$this->type = $type;
		$this->width = $witdh;
		
		$this->includeInRecordSummaryFields = array();
		$this->valueMap = array();
		$this->validators = array();
		$this->editorValueMap = array();
	}
	
	/**
	 * Implementation de object
	 * @see IRenderable::object()
	 */
	public function object() {
		return get_class($this);
	}

	/**
	 * Implementation de properties
	 * @see IRenderable::properties()
	 */
	public function properties() {
		return parent::getProp($this);
	}

	/**
	 * Implementation de scLog
	 * @see IRenderable::scLog()
	 */
	public function scLog() {
		ScCollectionLog::getInstance()->addSc(new ScLog($this->object(), get_object_vars($this)));
	}
	
	/**
	 * Implementation de render
	 * @see IScreen::render()
	 */
	public function render() {
		$this->scLog();
		return "{".$this->properties()."}";
	}
}
?>